import { UserItem } from '../userModel';
import { AverageUserQueryParams } from './model';
import { BasicFetchResult } from '/@/api/model/baseMode';
import { defHttp } from '/@/utils/http/axios';

import { ErrorMessageMode } from '/@/utils/http/axios/types';

enum Api {
  List = '/baseInfo/customerManager/findPage',
  ChangeStatus = '/baseInfo/customerManager/isUse',
  Delete = '/baseInfo/customerManager/delete',
}

/**
 * @description: 查询普通用户列表
 */
export function ListApi(params: AverageUserQueryParams, mode: ErrorMessageMode = 'modal') {
  return defHttp.get<BasicFetchResult<UserItem>>(
    {
      url: Api.List,
      params,
    },
    {
      errorMessageMode: mode,
    }
  );
}

/**
 * @description: 改变用户状态
 */
export function ChangeStatusApi(params: UserItem, mode: ErrorMessageMode = 'modal') {
  return defHttp.post(
    {
      url: Api.ChangeStatus,
      params,
    },
    {
      errorMessageMode: mode,
    }
  );
}

/**
 * @description: 删除用户
 */
export function DeleteApi(id: string, mode: ErrorMessageMode = 'modal') {
  return defHttp.get(
    {
      url: Api.Delete + `/${id}`,
    },
    {
      errorMessageMode: mode,
    }
  );
}
